package com.youli.gb.service.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.sun.imageio.plugins.common.I18N;
import com.youli.gb.mapper.SysRoleMapper;
import com.youli.gb.model.SysRole;
import com.youli.gb.service.ISysRoleService;
import com.youli.gb.utils.DBUtils;

public class SysRoleServiceImpl implements ISysRoleService {
	
	//注入mapper对象
	private SysRoleMapper roleMapper = DBUtils.getSqlSession().getMapper(SysRoleMapper.class);

	@Override
	public SysRole getById(int id) {
		SysRole role = roleMapper.getById(id);
		return role;
	}

	@Override
	public List<SysRole> getAll() {
		List<SysRole> list =  roleMapper.getAll();
		return list;
	}

	@Override
	public int add(String roleName, String description) {
		int ret =  roleMapper.add(new SysRole(roleName, description));
		return ret;
	}

	@Override
	public SysRole getByName(String roleName) {
		SysRole role =  roleMapper.getByName(roleName);
		return role;
	}

	@Override
	public int deleteById(Integer id) {
		return this.roleMapper.deleteById(id);
	}

	@Override
	public int deleteByIds(String[] ids) {
		return this.roleMapper.deleteByIds(ids);
	}

	@Override
	public int edit(Integer id, String roleName, String description) {
		int ret =  roleMapper.edit(new SysRole(id, roleName, description));
		return ret;
	}
	
}
